<?php

namespace App\Http\Controllers;

use App\Service\CatsService;
use App\Validation\CatsSearchValidation;

class CatsController extends BaseController
{
	/**
	 * [indexAction 分类列表]
	 * @return [type] [description]
	 */
	public function indexAction()
	{
		$raw = $this->validation(new CatsSearchValidation, $this->request->getJsonRawBody());

		$data = CatsService::getList($raw);	

		$count = CatsService::getList($raw, TRUE);
		$assign = [
			'total' => $count,
			'list'  => $data,
		];

		return $this->echoJson($assign);
	}

	/**
	 * [detailAction 分类详情]
	 * @return [type] [description]
	 */
	public function detailAction()
	{
		$id = $this->dispatcher->getParam('id');
		$data = CatsService::getInfo($id);
		return $this->echoJson($data);
	}
}